﻿using Agile.Service.Admin.Model.ViewModel.New;

namespace Agile.Service.Admin.WebApi.Controllers.Content;

/// <summary>
/// 信息服务接口
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class ContentNewsController : AgileControllerBase
{
    /// <summary> 添加 </summary> 
    [HttpPost]
    public async Task<ResponseResult<bool>> Insert(InsertNewInfoRequest request)
    => Result(await this.GetService<IContentNewsService>().InsertAsync(request, LoginUser().UserID, true));

    /// <summary> 修改 </summary> 
    [HttpPost]
    public async Task<ResponseResult<bool>> Update(UpdateNewInfoRequest request)
    => Result(await this.GetService<IContentNewsService>().UpdateAsync(request, LoginUser().UserID));

    /// <summary> 删除 </summary> 
    [HttpGet]
    public async Task<ResponseResult<bool>> Remove(long newID)
    => Result(await this.GetService<IContentNewsService>().RemoveAsync(newID, LoginUser().UserID));

    /// <summary> 查询 </summary> 
    [HttpPost]
    public async Task<ResponseResult<PageModel<QueryPageNewInfoResponse>>> QueryPage(QueryPageInfoNewInfoRequest request)
    => Result(await this.GetService<IContentNewsService>().QueryPageAsync(request));

    /// <summary> 查询明细 </summary> 
    [HttpGet]
    public async Task<ResponseResult<GetDetailNewInfoResponse>> GetDetail(long newID)
    => Result(await this.GetService<IContentNewsService>().GetDetailAsync(newID, false));

    /// <summary> 审核 </summary> 
    [HttpPost]
    public async Task<ResponseResult<bool>> Audit(AuditNewInfoRequest request)
    => Result(await this.GetService<IContentNewsService>().AuditAsync(request, LoginUser().UserID));

    /// <summary> 批量审核 </summary> 
    [HttpPost]
    public async Task<ResponseResult<bool>> BatchAudit(BatchAuditNewInfoRequest request)
    => Result(await this.GetService<IContentNewsService>().BatchAuditAsync(request, LoginUser().UserID));
}
